package com.ysh.c3p0;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/*
    关闭连接会返回连接到连接池，注意结果中con的地址值
 */
public class C3p0Test2 {
    public static void main(String[] args) throws SQLException {
        // 1.创建c3p0的数据库连接池对象
        DataSource dataSource = new ComboPooledDataSource("otherc3p0");
        // 2.测试
        for (int i = 0; i < 11; i++) {
            Connection con = dataSource.getConnection();
            System.out.println(i + ":" + con);

            if(i == 5){
                con.close();
            }
        }
    }
}
